<template>
  <div>
    <div class="dashboard-container">
      
      <div class="big-back-box">
        <div class="top" style="margin-bottom: 20px">用户注册</div>
        <!-- 卡片 -->
        <div style="width: 600px; margin: 0 auto">
          <el-form ref="form" :model="form" label-width="100px">
            <!-- 用户名 -->
            <el-form-item label="用户名">
              <el-input v-model="form.username" :disabled="false"></el-input>
            </el-form-item>
            <!-- 密码 -->
            <el-form-item label="密码">
              <el-input v-model="form.password" show-password></el-input>
            </el-form-item>
            <!-- 昵称 -->
            <el-form-item label="昵称">
              <el-input v-model="form.nickname" :disabled="false"></el-input>
            </el-form-item>
            <!-- 姓名 -->
            <el-form-item label="姓名">
              <el-input v-model="form.name" :disabled="false"></el-input>
            </el-form-item>
            <!-- 性别 -->
            <el-form-item label="性别">
              <el-input v-model="form.sex" :disabled="false"></el-input>
            </el-form-item>
            <!-- 出生日期 -->
            <el-form-item label="出生日期">
              <el-date-picker v-model="form.birthDate"   style="width: 40%" ></el-date-picker>
            </el-form-item>
            <!-- 所在地址 -->
            <el-form-item label="所在地址">
              <el-input v-model="form.address" :disabled="false"></el-input>
            </el-form-item>
            <!-- 手机号 -->
            <el-form-item label="手机号">
              <el-input v-model="form.phone" :disabled="false"></el-input>
            </el-form-item>
            <!-- 邮箱 -->
            <el-form-item label="邮箱">
              <el-input v-model="form.email" :disabled="false"></el-input>
            </el-form-item>
            <!-- 身份证号码 -->
            <el-form-item label="身份证号码">
              <el-input v-model="form.idCard" :disabled="false"></el-input>
            </el-form-item>
            <!-- 按钮 -->
            <el-form-item>
              <router-link to="/login">
                <el-button type="primary" @click="onSubmit">注册</el-button>
              </router-link>
              <router-link to="/dashboard">
                <el-button style="margin-left:20px">取消</el-button>
              </router-link>             
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {register} from '@/api/user'
import {getToken} from "@/utils/auth" 
export default {
  data() {
    return {
      token:{},  
      size: "",
      form: {
        username:"",
        password:"",
        email:"",
        nickname:"",
        name:"",
        sex:"",
        idCard:"",
        birthDate:"",
        address:"",
      },
    };
  },
  mounted(){
      this.token["token"]=getToken();
  },
  methods: {
      handleAvatarSuccess(res,file) {
       console.log(res);
        this.form.headPortrait=res.url;
        this.$message(res.message);
      },
    onSubmit() {
        register(this.form).then(resp=>{
        console.log(resp);
        this.$message(resp.data.message);
      })
    },
  },
};
</script>

<style lang="scss" scoped>


.dashboard-container{
  
}

avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }

// 页头LOGO
.top {
  height: 50px;
  font-size: 30px;
  text-align: center;
  line-height: 50px;
}

// 大盒子
.big-back-box {
  width: 1080px;
  margin: 0 auto;
}

// 原框架自带
.dashboard {
  &-container {
    margin-top: 30px;
    // margin-left: 30px;
    // margin-right: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}

// 页脚
.footer {
  height: 300px;
  background-color: blue;
}
.footer-back-box {
  width: 1080px;
  margin-left: 45px;
}
.footer-title {
  height: 30px;
  line-height: 40px;
  padding-left: 10px;
}
.footer-link-card {
  width: 200px;
  background-color: orange;
  margin-left: 10px;
}

// 模板-卡片
.text {
  font-size: 14px;
}
.item {
  padding: 18px 0;
}
.box-card {
  width: 480px;
}
</style>